/**
 * 获取数据基类
 */
import axios from "axios";
interface RequestParams {
  url: string;
  method: string;
  data?: any;
  dataType?: string;
}
export default class ObtainData {
  async getRequestData(params: RequestParams) {
    const { url, method } = params;
    if (!url || !method) return;
    const requestConfig: any = { url, method };
    params.dataType === "body" && (requestConfig.data = params.data);
    params.dataType === "params" && (requestConfig.params = params.data);
    const data = await axios(requestConfig);
    return data.data;
  }
}